feat(csharp): add C# language template filters - #218
Merged
Conversation
Add a filtercs package providing C# code-generation filters and register them in the shared template FuncMap. Functions: csReturn/csType, csDefault, csParam(s), csVar(s), csTestValue, csAsyncReturn (Task<T>), csNs/csNsOpen/csNsClose (block namespaces), and csExtern(s) reading cs.namespace/name/default/using/package/version meta. Type mapping: scalars to C# primitives, arrays to List<T>, interfaces are I-prefixed, async returns wrap in Task<T>, and namespaces are block-scoped. Extern test fixtures gain additive cs.* meta keys. The filters are unit-tested in isolation against the shared testdata fixtures.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
filtercspackage providing C# code-generation template filters, registered into the shared templateFuncMap(pkg/gen/filters/funcmap.go) alongside the other supported languages.The filters are pure model→string functions and are independent of any SDK template; a template opts in by calling
{{ csReturn . }}and friends.Filters
csReturn/csTypecsDefaultcsParam/csParamsType name, comma-joinedcsVar/csVarscsTestValuecsAsyncReturnTask<T>(Taskfor void)csNs/csNsOpen/csNsClosecsExtern/csExternscs.namespace/cs.name/cs.default/cs.using/cs.package/cs.versionmetaType mapping
int,long,float,double,bool,string);bytes→byte[];any→objectList<T>I-prefixedTask<T>Testing
Every filter is unit-tested in isolation against the shared
pkg/gen/filters/testdatafixtures. The extern fixtures gain additivecs.*meta keys; other languages read only their own keys, so this is non-breaking.go test ./...— all greengofmt/go vet/staticcheck— clean